package com.x.Part11_多态;

/**
 * ClassName: PersonTest
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.02.28 15:34
 */
public class PersonTest {
    public static void main(String[] args) {

        //多态
        Person p1 = new Man();
        Person p2 = new Women();

        //多态应用
        p1.eat();//男人吃饭
        p2.eat();//女人吃饭


        System.out.println("**************");
        if(p1 instanceof Man){
            Man m1 =(Man) p1;
            m1.Smocking();
        }

        if(p2 instanceof Women){
            Women w1 =(Women) p2;
            w1.Watching();
        }
    }
}
